package cdu.sl.controller;

import cdu.sl.pojo.GenderOption;
import cdu.sl.pojo.JobOption;
import cdu.sl.pojo.Result;
import cdu.sl.pojo.StudentOption;
import cdu.sl.service.ReportService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RequestMapping("/report")
@RestController
public class ReportController {

    private static final Logger log = LoggerFactory.getLogger(ReportController.class);

    @Autowired
    private ReportService reportService;

    /**
     * 统计员工职位人数
     *
     * @return 员工职位信息 （包含职位和value）
     */
    @GetMapping("empJobData")
    public Result getEmpJobData() {
        log.info("统计员工职位人数");
        JobOption jobOption = reportService.getEmpJobData();
        return Result.success(jobOption);
    }

    /**
     * 统计员工性别信息
     */
    @GetMapping("/empGenderData")
    public Result getEmpGenderData() {
        log.info("统计员工性别信息");
        List<Map<String, Object>> genderList = reportService.getEmpGenderData();
        return Result.success(genderList);
    }

    /**
     * 统计学生学历信息
     * @return
     */
    @GetMapping("/studentDegreeData")
    public Result getStudentDegreeData(){
        log.info("统计学生学历信息");
        List<Map<String,Integer>> degreeList=reportService.getStudentDegreeData();
        return Result.success(degreeList);
    }

    /**
     * 统计学生人数信息
     */
    @GetMapping("/studentCountData")
    public Result getStudentCountData(){
        log.info("统计学生人数信息");
        StudentOption studentOption=reportService.getStudentCountData();
        return Result.success(studentOption);
    }

}
